﻿@using Kairos.Views

@model IEnumerable<Kairos.Models.Document>

@{
    ViewBag.Title = "Documents";
}

@using (Html.BeginForm("Create", "CookieDocs"))
{
    @Html.AntiForgeryToken()
    @Html.ValidationSummary(true)

    <fieldset>
        <legend>Documents</legend>

        <table align="center" style="width:100%">
            <tr>
                <td colspan="2">
                    <div class="content-wrapper">
                        @Html.TextBox("search", ViewBag.Search as string, new { @class = "search ui-corner-all" })
                    </div>
                </td>
            </tr>
            <tr>
                <td align="right" style="padding:10px;">
                    <div class="editor-field">
                        @Html.DropDownList("MetaData_1ID", (SelectList)ViewBag.MetaData1, "Tous type de document", new { @class = "ui-corner-all" })
                    </div>
                </td>
                <td align="left" style="padding:10px;">
                    <div class="editor-field">
                        @Html.DropDownList("MetaData_2ID", (SelectList)ViewBag.MetaData2, "Tous logiciel associé", new { @class = "ui-corner-all" })
                    </div>
                </td>
            </tr>
            <tr>
                <td colspan="2" align="center">
                    <input type="submit" value="Rechercher" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" />
                </td>
            </tr>
            @if (ViewBag.ShouldDisplayUI(Kairos.Roles.Administrator | Kairos.Roles.Worker))
            {
                <tr>
                    <td colspan="2" align="center">
                        @Html.ButtonLink("Nouveau document", "Create", "Doc", null, new { @class = "ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" })
                    </td>
                </tr>
            }
        </table>

    </fieldset>
}

@if (Model.Count() == 0)
{
    if (ViewBag.IsResult == true)
    {
        <p>
            Aucun document ne correspond aux critères spécifiés.
        </p>
    }
}
else
{
    <table>
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.Titre)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.DateCreation)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.DateModification)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.DateExpiration)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.UserCreation)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.UserModification)
            </th>
            <th></th>
        </tr>

        @foreach (var item in Model)
        {
            <tr>
                <td>
                    @Html.DisplayFor(modelItem => item.Titre)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.DateCreation)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.DateModification)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.DateExpiration)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.UserCreation)
                </td>
                <td>
                    @Html.DisplayFor(modelItem => item.UserModification)
                </td>
                <td>
                    @Html.ActionLink("Détails", "Details", "Doc", new { id = item.ID }, null)
                </td>
            </tr>
        }
    </table>

    @Html.Partial("_Pager")
}
